package com.wanmait.employment.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.wanmait.employment.entity.Nation;
import com.wanmait.employment.mapper.NationMapper;
import com.wanmait.employment.service.NationService;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

@Service
public class NationServiceImpl implements NationService {

    @Resource
    private NationMapper nationMapper;

    @Override
    public PageInfo<Nation> selectList(String title, int pageNum, int pageSize) {
        PageHelper.startPage(pageNum,pageSize);
        QueryWrapper<Nation> queryWrapper=new QueryWrapper<>();
        queryWrapper.like("title",title);
        List<Nation> nationList=nationMapper.selectList(queryWrapper);
        PageInfo<Nation> nationPageInfo=new PageInfo<>(nationList);
        return nationPageInfo;
    }


    @Override
    public void update(Nation nation) {
        nationMapper.updateById(nation);
    }

    @Override
    public void insert(Nation nation) {
        nationMapper.insert(nation);
    }

    @Override
    public void delete(Integer id) {
        nationMapper.deleteById(id);
    }
}
